package com.sfh.cpc;

import android.Manifest;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.content.ContextCompat;

import com.jaeger.library.StatusBarUtil;
import com.sfh.cpc.com.entity.EMass;
import com.sfh.cpc.com.ui.BasePermissionsActivity;
import com.sfh.cpc.home.NavFragment;
import com.sfh.cpc.com.nav.NavigationButton;
import com.sfh.cpc.com.nav.OnTabReselectListener;
import com.sfh.cpc.mass.MassActivity;
import com.sfh.lib.ui.AbstractLifecycleActivity;

public class MainActivity extends BasePermissionsActivity implements NavFragment.OnNavigationReselectListener {


    public static void startUI(Context context) {

        Intent intent = new Intent(context, MainActivity.class);
        context.startActivity(intent);
    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        StatusBarUtil.setColor(this, ContextCompat.getColor(this, R.color.bg),0);
        init();
    }

    private void init(){
        FragmentManager manager = getSupportFragmentManager();
        NavFragment mNavBar = ((NavFragment) manager.findFragmentById(R.id.homeFagNav));
        mNavBar.setup(this, manager, R.id.homeContainer, this);
        hasPermissions();
    }

    @Override
    public void onReselect(NavigationButton navigationButton) {
        Fragment fragment = navigationButton.getFragment();
        if (fragment != null
                && fragment instanceof OnTabReselectListener) {
            OnTabReselectListener listener = (OnTabReselectListener) fragment;
            listener.onTabReselect();
        }
    }

    @Override
    public String[] getPermissions() {
        return new String[]{Manifest.permission.CAMERA,Manifest.permission.WRITE_EXTERNAL_STORAGE};
    }


}
